package com.vend.main.home
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import com.alibaba.android.arouter.facade.annotation.Route
import com.flyco.tablayout.CommonTabLayout
import com.vend.common.base.BaseActivity
import com.vend.common.base.BaseFragment
import com.vend.common.base.model.FragmentType
import com.vend.common.constant.RouterConstant
import com.vend.common.mvp.IPresenter
import com.vend.common.mvp.IView
import com.vend.main.R
import com.vend.main.home.presenter.HomePresenter
import kotlinx.android.synthetic.main.activity_main_home.*

/**
 * Created by glendal on 2022/01/24.
 * 首页的界面显示
 */
@Route(path = RouterConstant.MAIN_HOME)
class HomeActivity : BaseActivity<HomePresenter>(),HomeView {
    override fun getContentLayoutId(): Int {
        return R.layout.activity_main_home
    }

    override fun initView(savedInstanceState: Bundle?) {
         mPresenter = HomePresenter(this,this,supportFragmentManager)
         mPresenter?.start()
    }

    override fun onDestroy() {
        super.onDestroy()
        mPresenter?.stop()
    }
    /**
     * 防止有些界面会重叠
     */
    override fun onAttachFragment(fragment: Fragment) {
        super.onAttachFragment(fragment)
        mPresenter?.attachFragment(fragment)

    }
    override fun getViewPage(): ViewPager {
        return mViewPager
    }

    override fun getTabLayout(): CommonTabLayout {
        return mCustomLayout
    }
}
interface HomeView: IView{
    /**
     * 获取ViewPage
     */
    fun getViewPage() : ViewPager
    /**
     *获取TabLayout
     */
    fun getTabLayout() : CommonTabLayout
}